/*
This software is distributed under the Simplified BSD License:

Copyright (c) 2008, Chris Venter <chris.venter@gmail.com>
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, 
are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice, 
    	this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice, 
    	this list of conditions and the following disclaimer in the documentation 
    	and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
DAMAGE.
*/
#ifndef GENERIK_GTK_MACROS_H
#define GENERIK_GTK_MACROS_H

/** \file macros.h
This file provides a couple of macros, along the same lines as the ones in the tracing.h
code.
They make the usage of the wrapper classes for the gtk gang easier.
*/

/** \def GENERIK_GTK_GLOBAL
This macro instantiates the recursive mutex used by the gdk_threads_enter() and gdk_threads_leave()
functions, and initialises the depth counter to zero.
Use it globally once in source code, prefereably in the same spot as GENERIK_TRACER_GLOBAL.
*/
#define GENERIK_GTK_GLOBAL \
	GStaticRecMutex generik::gdk::threads_init::_mutex = G_STATIC_REC_MUTEX_INIT; \

/** \def GENERIK_GDK_TRACE_DEPTH
This macro logs the current depth of the recursive mutex, using the generik tracing functionality
*/
#define GENERIK_GDK_TRACE_DEPTH \
	GENERIK_TRACE("GENERIK GDK DEPTH: "<<generik::gdk::threads_init::_count)

/** \def GENERIK_GTK_INIT
This macro declares a generik::gtk::init object instance, which initialises the gtk library gang.
Use it at the start of code to initialise and set up gtk.
*/
#define GENERIK_GTK_INIT  generik::gtk::init generik_gtk_init(argc, argv)

/** \def GENERIK_GDK_ENTER
This macro defines a generik::gdk_threads_enter object. This object holds a lock on the 
recursive mutex as long as it is alive. It can be used to scope-lock any gdk drawing functions.
*/
#define GENERIK_GDK_ENTER generik::gdk::threads_enter generik_gdk_threads

/** \def GENERIK_GTK_MAIN
Convenience macro which starts up the gtk main loop
*/
#define GENERIK_GTK_MAIN \
	gdk_threads_enter(); \
	generik::gtk::main(); \
	gdk_threads_leave()

/** \def GENERIK_GTK_QUIT
Convenience macro which issues a gtk quit event
*/
#define GENERIK_GTK_QUIT  generik::gtk::quit()




#endif



